import request from '@/utils/request'
import querystring from 'querystring'

/**
 * 查看详情
 * @param {*} id 
 */
export function getRapidById(id) {
  return request.get(`/rapid/detail/${id}`)
}

/**
 * 保存快速单
 * @param {*} param 
 */
export function addRapid(param) {
  return request.post('/rapid/save', param)
}
/**
 * 快速工单-编辑
 * @param {*} param 
 */
export function editRapid(param) {
  return request.put('/rapid/save', param)
}

export function deleteRapid(id) {
  return request.delete('/rapid/del/' + id)
}

/**
 * 快速单分页
 * @param {*} param 
 * @param {*} pageSize 
 * @param {*} pageNo 
 */
export function rapidList(param, pageSize, pageNo) {
  const data = {
    pageNo,
    pageSize,
    param: {
      ...param
    }
  }
  return request.post('/rapid/page', data)
}
/**
 * 快速单子项目分页
 * @param {*} param 
 * @param {*} pageSize 
 * @param {*} pageNo 
 */
export function rapidProjectList(param, pageSize, pageNo) {
  const data = {
    pageNo,
    pageSize,
    param: {
      ...param
    }
  }
  return request.post('/rapidProject/page', data)
}

/**
 * 快速单返工确认
 * @param {*} param 
 */
export function rapidProjectReworkSave(param) {
  return request.put('/rapidProjectRework/rework', param)
}

/**
 * 快速单配件分页查询
 * @param {*} param 
 * @param {*} pageSize 
 * @param {*} pageNo 
 */
export function rapidPartsPage(param, pageSize, pageNo) {
  const data = {
    pageNo,
    pageSize,
    param: {
      ...param
    }
  }
  return request.post('/rapid/partsPage', data)
}
/**
 * 返工分页列表
 * @param {*} param 
 * @param {*} pageSize 
 * @param {*} pageNo 
 */
export function rapidProjectReworkPage(param, pageSize, pageNo) {
  const data = {
    pageNo,
    pageSize,
    param: {
      ...param
    }
  }
  return request.post('/rapidProjectRework/page', data)
}


//工单预付款
export function rapidImprest(param) {
  return request.put(`/rapid/imprest`, param)
}

//工单增项
export function rapidInsProject(param) {
  return request.put(`/rapid/insProject`, param)
}

//获取客户信息
export function getClientById(id) {
  return request.get(`/rapid/client/${id}`)
}

//--del工单派工
export function rapidDispatch(id) {
  return request.get(`/rapid/client/${id}`)
}

//生成工单编号
export function rapidGetWorkOrderCode() {
  return request.get(`/rapid/getWorkOrderCode`)
}

/**
 * 快速单编辑详情
 * @param {*} id 
 */
export function rapidFindById(id) {
  return request.get(`/rapid/findById/${id}`)
}

/**
 * 工单派工
 * @param {*} id 
 */
export function getRapidDispatch(id) {
  return request.get(`/rapid/dispatch/${id}`)
}

/**
 * 配件退料
 * @param {*} param 
 */
export function rapidReturnMaterial(param) {
  return request.post(`/rapid/returnMaterial`,param)
}
